﻿
// Condition: 5. Write a method that checks if the element at given position in given array of integers is bigger than its two neighbors (when such exist).

using System;


class BiggerNeighbor
{
    static string Answer(int index, int[] array)
    {
        if (index == 0 || index == array.Length - 1)
        {
            return "has only one neighbor.";
        }
        else if (array[index] > array[index + 1] &&
                    array[index] > array[index - 1])
        {
            return "is bigger than its two neighbors.";
        }
            
        return "is not bigger than both of its neightbors.";
           
    }

    static void Main(string[] args)
    {
        Console.Write("Enter number of elements in the array: ");
        int element = int.Parse(Console.ReadLine());
        int[] array = new int[element];
        // read array elements from console
        for (int i = 0; i < element; i++)
        {
            Console.Write("Element[{0}] = ", i);
            array[i] = int.Parse(Console.ReadLine());
        }

        // print the array
        Console.Write("The array is {");
        for (int i = 0; i < array.Length; i++)
        {
            Console.Write(array[i]+" ");
        }
        Console.Write("}");

        Console.WriteLine();
        Console.Write("Enter index between 0 and {0} include: ",array.Length-1);
        int index = int.Parse(Console.ReadLine());
        Console.WriteLine("The element[{0}]={2} {1}",index, Answer(index,array),array[index]);

    }
}

